package airthmetic;

import java.util.Scanner;
import javax.swing.JOptionPane;

public class Request {
	static int num1,sum;
	static int num2;
	static int num3;
	static int type;

	public static int add(int a, int b) {
		return a + b;
	}

	public static int sub(int a, int b) {
		return a - b;
	}

	public static int mul(int a, int b) {
		return a * b;
	}

	public static int div(int a, int b) {
		return a / b;
	}

	public static void main(String[] args) {

		
		inflow();
		
		switch (type) {
		case 1:
			sum=add(num1,num2);
			break;
		case 2:
			sum=sub(num1,num2);
			break;
		case 3:
			sum=mul(num1, num2);
			break;
		case 4:
			sum=div(num1,num2);
			break;
		default:
			break;
		}
		outflow();
		judge();
	}

	public static void inflow() {
		Scanner scan = new Scanner(System.in);
		
		num1=(int)(1+Math.random()*(100-1+1));
		num2=(int)(1+Math.random()*(100-1+1));
		type=(int)(1+Math.random()*(4-1+1));
		// 输出猜测结果
	}

	public static void outflow() {
		Scanner scan = new Scanner(System.in);
		System.out.print(num1);
		if(type==1)
			System.out.print("+");
		else if(type==2)
			System.out.print("-");
		else if(type==3)
			System.out.print("*");
		else if(type==4)
			System.out.print("/");
		System.out.println(num2);
		System.out.println("输入猜测结果:");
		num3 = scan.nextInt();
		System.out.println("正确结果:");
		System.out.println(sum);
		return;
	}
	
	public static void judge(){
		if(num3==sum)
			JOptionPane.showMessageDialog(null,"你咋不上天，和太阳肩并肩呢！" ,"正确",JOptionPane.INFORMATION_MESSAGE);
		else{
			Object[] possibleValues = { "是在下输了！", "我不服！" }; 
			Object selectedValue = JOptionPane.showInputDialog(null, "傻逼了吧！", "错误", JOptionPane.ERROR_MESSAGE, null, possibleValues, possibleValues[0]);
		}
			
	}
	
}
